import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<String> lst = new ArrayList<>();
        HashMap<String, Integer> map = new HashMap<>();
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String s = in.next();
            String line_num = in.next();
            String[] ss = s.split("\\\\");
            int len = ss[ss.length - 1].length();
            String str = "";

            if (len > 16) {
                str = str + ss[ss.length - 1].substring(len - 16, len);
            } else {
                str = str + ss[ss.length - 1];
            }
            str = str + " " + line_num;
            if (!map.containsKey(str)) {
                map.put(str, 1);
                lst.add(str);
            } else {
                map.put(str, map.get(str) + 1);
            }

        }
        int start = 0;
        if (lst.size() > 8) {
            start = lst.size() - 8;
        }
        for (; start < lst.size(); start++) {
            System.out.println(lst.get(start) + " " + map.get(lst.get(start)));
        }
    }
}